package com.example.controller.guava;

import com.example.annotation.PassToken;
import com.example.entity.User;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Optional;

/**
 * @author ChenXiaoBin
 * on 2020-03-13
 */
@RestController
@RequestMapping("/V1.0/option")
public class OptionalController {

    @PutMapping("")
    @PassToken
    @ApiOperation(value = "optional", notes = "optional")
    public void optional() {
     User user = new User();
     user.setId(1);
     User d = null;
      Optional.ofNullable(user)
                .map(u -> u.getWxId())
                .map(z -> z.equals("3"))
                .orElse(false);
    }

    @PassToken
    @ApiOperation(value = "表驱动消除if-else", notes = "表驱动消除if")
    @PutMapping("/drive")
    public void drive() {

    }
}
